package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.domain.Student;
import com.itheima.pojo.dto.StudentPageQueryDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface StudentMapper {
    //查询学生列表
    Page<Student> list(@Param("spqdto") StudentPageQueryDTO spqdto);

    //查询学生信息
    Student listById(@Param("id") Integer id);

    void addStudentInfo(Student student);

    void deleteByIds(@Param("ids") List<Integer> ids);

    void updateStudentInfo(@Param("student") Student student);

    //根据班级id查询学生信息
    List<Student> listStudentByClazzId(Integer id);

    @Update("update student set violation_count = #{counts} + 1  where id = #{id}")
    void updateViolation(@Param("id") Integer id,@Param("counts") Short counts);
    //根据id查询扣分次数
    @Select("select violation_count from student where id=#{id}")
    short selStudentCount(Integer id);

    //通过id查询到原来的分数
    @Select("select violation_score from student where id= #{id}")
    Short selStudentScore(Integer id);


}
